package com.ls.mybatis.core;


public class ConnectionPoolFactory {
    private static ConnectionPool connectionPool = null;

    private ConnectionPoolFactory(){

    }

    protected synchronized static void create(){
        if(connectionPool == null){
            connectionPool = new ConnectionPool();
            try {
                //创建数据库连接池
                connectionPool.createPool();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    protected synchronized static void create(String driverClass, String url, String userName, String passWord){
        if(connectionPool == null){
            connectionPool = new ConnectionPool(driverClass, url, userName, passWord);
            try {
                //创建数据库连接池
                connectionPool.createPool();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    protected  static ConnectionPool getInstance(){
        return  connectionPool;
    }
}
